﻿#include "stdafx.h"
#include "S_MonitorDisplayingManager.h"

#include "Source/MonitorModule/S_MonitorDataContainer.h"
#include "Source/MonitorModule/S_MonitorTreeManager.h"
#include "Source/ModelingPreModule/S_ModelingPre_InteractiveManager.h"
#include "Source/ModelingPreModule/Visible/S_ModelingPre_VisibleManager.h"

/*
-----==========================================================-----
		类：		场强探头模块 - 模型显示管理.h
		作者：		drill_up
		所属模块：	场强探头模块
		功能：		此类定义该模块数据所需要显示的模型。
					【只管理 数据容器 显示模型，编辑窗口的临时模型数据不管】
					（详细见cpp）
-----==========================================================-----
*/
S_MonitorDisplayingManager::S_MonitorDisplayingManager() {

	// > 阻塞设置
	this->m_block_refreshModel_Probe = false;
	this->m_block_refreshModel_CurrentMonitor = false;
	this->m_block_refreshModel_VoltageMonitor = false;

	// > 数据变化信号
	connect(S_MonitorDataContainer::getInstance(), &S_MonitorDataContainer::containerDataAdded, this, &S_MonitorDisplayingManager::containerDataAdded);
	connect(S_MonitorDataContainer::getInstance(), &S_MonitorDataContainer::containerDataModifyed, this, &S_MonitorDisplayingManager::containerDataModifyed);
	connect(S_MonitorDataContainer::getInstance(), &S_MonitorDataContainer::containerDataDeleted, this, &S_MonitorDisplayingManager::containerDataDeleted);
	connect(S_MonitorDataContainer::getInstance(), &S_MonitorDataContainer::containerGlobalDataModifyed, this, &S_MonitorDisplayingManager::containerGlobalDataModifyed);
	connect(S_MonitorDataContainer::getInstance(), &S_MonitorDataContainer::containerDataAllReloaded, this, &S_MonitorDisplayingManager::containerDataAllReloaded);

}
S_MonitorDisplayingManager::~S_MonitorDisplayingManager() {
}

/* --------------------------------------------------------------
---------- 单例
*/
S_MonitorDisplayingManager* S_MonitorDisplayingManager::cur_manager = NULL;
S_MonitorDisplayingManager* S_MonitorDisplayingManager::getInstance() {
	if (cur_manager == NULL) {
		cur_manager = new S_MonitorDisplayingManager();
	}
	return cur_manager;
}


/*-----------------------------------
		模型标记 - 模型重建
*/
void S_MonitorDisplayingManager::rebuildAll() {

	// > 场强探头
	this->refreshModelAll_NoUpdate_Probe();

	// > 电流监视器
	this->refreshModelAll_NoUpdate_CurrentMonitor();

	// > 电压监视器
	this->refreshModelAll_NoUpdate_VoltageMonitor();
}



/*-----------------------------------
		场强探头 - 刷新模型
*/
void S_MonitorDisplayingManager::refreshModel_NoUpdate_Probe(QString data_id) {
	if (this->m_block_refreshModel_Probe == true) { return; }

	// > 清理模型
	this->clearModel_NoUpdate_Probe(data_id);

	// > 获取数据
	C_FieldProbe c_data = S_MonitorDataContainer::getInstance()->getDataFieldProbeById(data_id);
	if (c_data.isNull()) { return; }

	// > 方向 (0:X, 1:Y, 2:Z, 3:All(X, Y, Z, Abs)
	QString model_id_x;
	QString model_id_y;
	QString model_id_z;
	bool axis[3] = { false, false, false }; // 声明一个长度为 3 的数组，用于存储需要设置为 true 的变量
	if (c_data.m_OrientationType == 0 || c_data.m_OrientationType == 3) {
		axis[0] = true; // 如果 c_data.mOrientationType 为 0 或 3，则设置 x 轴为 true
	}
	if (c_data.m_OrientationType == 1 || c_data.m_OrientationType == 3) {
		axis[1] = true; // 如果 c_data.mOrientationType 为 1 或 3，则设置 y 轴为 true
	}
	if (c_data.m_OrientationType == 2 || c_data.m_OrientationType == 3) {
		axis[2] = true; // 如果 c_data.mOrientationType 为 2 或 3，则设置 z 轴为 true
	}

	// > 遍历数组中的每个元素
	for (int i = 0; i < 3; i++) {
		if (axis[i]) { // 如果该元素为 true，则依次创建对应的 FieldProbe 实例并更改透明度
			double x = c_data.m_PosX;
			double y = c_data.m_PosY;
			double z = c_data.m_PosZ;

			QColor color = QColor(Qt::gray);
			if (i == 0) { // 如果 i 为 0，则创建 x 方向的 FieldProbe 实例
				 model_id_x = S_ModelingPre_InteractiveManager::getInstance()->model_CreateFieldProbe(
					x, y, z,
					1, 0, 0, color, false
				);
			}
			if (i == 1) { // 如果 i 为 1，则创建 y 方向的 FieldProbe 实例
				 model_id_y = S_ModelingPre_InteractiveManager::getInstance()->model_CreateFieldProbe(
					x, y, z,
					0, 1, 0, color, false
				);
			}
			if (i == 2) { // 如果 i 为 2，则创建 z 方向的 FieldProbe 实例
				 model_id_z = S_ModelingPre_InteractiveManager::getInstance()->model_CreateFieldProbe(
					x, y, z,
					0, 0, 1, color, false
				);
			}
		}
	}

	this->m_mapProbe.insert(data_id, QStringList() << model_id_x << model_id_y << model_id_z);
}
void S_MonitorDisplayingManager::refreshModelAll_NoUpdate_Probe() {
	if (this->m_block_refreshModel_Probe == true) { return; }

	// > 清理模型
	this->clearModelAll_NoUpdate_Probe();

	// > 遍历
	QStringList id_list = S_MonitorDataContainer::getInstance()->getDataFieldProbeAllId();
	for (int i = 0; i < id_list.count(); i++) {
		QString id = id_list.at(i);
		this->refreshModel_NoUpdate_Probe(id);
	}
}
/*-----------------------------------
		场强探头 - 清理模型
*/
void S_MonitorDisplayingManager::clearModel_NoUpdate_Probe(QString data_id) {
	QStringList model_id_list = this->m_mapProbe.value(data_id);
	if (model_id_list.count() == 0) { return; }
	for (int i = 0; i < model_id_list.count(); i++) {
		QString model_id = model_id_list.at(i);
		S_ModelingPre_InteractiveManager::getInstance()->model_destory(model_id, false);
	}
	this->m_mapProbe.remove(data_id);
}
void S_MonitorDisplayingManager::clearModelAll_NoUpdate_Probe() {
	QList<QStringList> modelId_tank = this->m_mapProbe.values();
	for (int i = 0; i < modelId_tank.count(); i++) {
		QStringList model_id_list = modelId_tank.at(i);
		for (int j = 0; j < model_id_list.count(); j++) {
			QString model_id = model_id_list.at(j);
			S_ModelingPre_InteractiveManager::getInstance()->model_destory(model_id, false);
		}
	}
	this->m_mapProbe.clear();
}
/*-----------------------------------
		场强探头 - 阻塞刷新模型
*/
void S_MonitorDisplayingManager::block_refreshModel_NoUpdate_Probe(bool enabled) {
	this->m_block_refreshModel_Probe = enabled;
}
/*-----------------------------------
		场强探头 - 设置数据显示（action）
*/
void S_MonitorDisplayingManager::action_show_Probe() {
	QAction* cur_action = qobject_cast<QAction*>(this->sender());		//从action里面取出数据指针
	QString data_id = cur_action->data().value<QString>();

	S_MonitorDataContainer::getInstance()->setVisible_Probe(data_id, true);
	this->refreshVisible_Probe(data_id);
}
void S_MonitorDisplayingManager::action_showAll_Probe() {
	S_MonitorDataContainer::getInstance()->setAllVisible_Probe(true);
	this->refreshVisible_ProbeAll();
}
void S_MonitorDisplayingManager::action_hide_Probe() {
	QAction* cur_action = qobject_cast<QAction*>(this->sender());		//从action里面取出数据指针
	QString data_id = cur_action->data().value<QString>();

	S_MonitorDataContainer::getInstance()->setVisible_Probe(data_id, false);
	this->refreshVisible_Probe(data_id);
}
void S_MonitorDisplayingManager::action_hideAll_Probe() {
	S_MonitorDataContainer::getInstance()->setAllVisible_Probe(false);
	this->refreshVisible_ProbeAll();
}

/*-----------------------------------
		场强探头显示 - 刷新显示
*/
void S_MonitorDisplayingManager::refreshVisible_Probe(QString data_id) {
	this->refreshVisible_ProbeNoSignal(data_id);

	// > 刷新视图+信号
	S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
	emit signal_visibleChanged_Probe();
}

void S_MonitorDisplayingManager::refreshVisible_ProbeNoSignal(QString data_id) {
	QStringList model_id_list = this->m_mapProbe.value(data_id);
	if (model_id_list.count() == 0) { return; }
	bool visible = true;

	// > 显示 - 内部隐藏列表 有此设置，则不显示
	if (this->m_customHideList_Probe.contains(data_id)){
		visible = false;
	}

	// > 显示 - 如果选中了树节点，则根据树节点情况显示
	if (S_MonitorTreeManager::getInstance()->hasItemSelectedID_Probes()) {
		QStringList selected_port_id = S_MonitorTreeManager::getInstance()->getItemSelectedID_Probes();
		if (selected_port_id.contains(data_id)) {
			visible = true;
		}else{
			visible = false;
		}
	}

	// > 显示 - 数据隐藏列表 有此设置，则不显示（注意顺序，数据隐藏的优先级最高）
	QStringList hide_idList = S_MonitorDataContainer::getInstance()->getHideList_Probe();
	if (hide_idList.contains(data_id)) { visible = false; }

	// > 显示 - 执行模型显示
	if (visible == true) {
		for (int i = 0; i < model_id_list.count(); i++) {
			QString model_id = model_id_list.at(i);
			S_ModelingPre_InteractiveManager::getInstance()->model_show(model_id, false); //显示

			//（ 2025-10-11 目前还没找到很好的修改颜色的办法）
			//S_ModelingPre_InteractiveManager::getInstance()->model_setSelected(model_id, true, false);
		}
	}else{
		for (int i = 0; i < model_id_list.count(); i++) {
			QString model_id = model_id_list.at(i);
			S_ModelingPre_InteractiveManager::getInstance()->model_hide(model_id, false); //隐藏
			
			//S_ModelingPre_InteractiveManager::getInstance()->model_setSelected(model_id, false, false);
		}
	}
}
void S_MonitorDisplayingManager::refreshVisible_ProbeAll() {
	QStringList id_list = S_MonitorDataContainer::getInstance()->getDataFieldProbeAllId();
	for (int i = 0; i < id_list.count(); i++) {
		QString id = id_list.at(i);
		this->refreshVisible_ProbeNoSignal(id);
	}

	// > 刷新视图+信号
	S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
	emit signal_visibleChanged_Probe();
}
/*-----------------------------------
		场强探头显示 - 是否显示
*/
bool S_MonitorDisplayingManager::isVisible_Probe(QString data_id) {
	QStringList model_id_list = this->m_mapProbe.value(data_id);
	if (model_id_list.count() == 0) { return true; }
	return S_ModelingPre_VisibleManager::getInstance()->model_isShowing(model_id_list.first());
}
/*-----------------------------------
		场强探头显示 - 设置隐藏列表（内部用）
*/
void S_MonitorDisplayingManager::setCustomHideList_Probe(QStringList data_id_list) {
	this->m_customHideList_Probe = data_id_list;
}
QStringList S_MonitorDisplayingManager::getCustomHideList_Probe() {
	return this->m_customHideList_Probe;
}



/*-----------------------------------
		电流监视器 - 刷新模型
*/
void S_MonitorDisplayingManager::refreshModel_NoUpdate_CurrentMonitor(QString data_id) {
	if (this->m_block_refreshModel_CurrentMonitor == true) { return; }

	// > 清理模型
	this->clearModel_NoUpdate_CurrentMonitor(data_id);

	// > 获取数据
	C_CurrentMonitor c_data = S_MonitorDataContainer::getInstance()->getDataCurrentMonitorById(data_id);
	if (c_data.isNull()) { return; }

	gp_Pnt p1 = gp_Pnt(c_data.x1, c_data.y1, c_data.z1);
	gp_Pnt p2 = gp_Pnt(c_data.x2, c_data.y2, c_data.z2);
	gp_Pnt p3 = gp_Pnt(c_data.x3, c_data.y3, c_data.z3);
	DSEM::Point3D temp_p_4 = c_data.getQuadrilateralVertex();
	gp_Pnt p4 = gp_Pnt(temp_p_4.X(), temp_p_4.Y(), temp_p_4.Z());

	QStringList modelId_list;
	bool invertDirection = c_data.directionInverted;
	if (invertDirection == false) {
		QString model_id_1 = S_ModelingPre_InteractiveManager::getInstance()->model_CreateDiscretePort(p1, p2, QColor(205, 55, 0), QColor(205, 55, 0), false);
		QString model_id_2 = S_ModelingPre_InteractiveManager::getInstance()->model_CreateDiscretePort(p2, p3, QColor(205, 55, 0), QColor(205, 55, 0), false);
		QString model_id_3 = S_ModelingPre_InteractiveManager::getInstance()->model_CreateDiscretePort(p3, p4, QColor(205, 55, 0), QColor(205, 55, 0), false);
		QString model_id_4 = S_ModelingPre_InteractiveManager::getInstance()->model_CreateDiscretePort(p4, p1, QColor(205, 55, 0), QColor(205, 55, 0), false);
		modelId_list.append(model_id_1);
		modelId_list.append(model_id_2);
		modelId_list.append(model_id_3);
		modelId_list.append(model_id_4);
	} else {
		QString model_id_1 = S_ModelingPre_InteractiveManager::getInstance()->model_CreateDiscretePort(p1, p4, QColor(205, 55, 0), QColor(205, 55, 0), false);
		QString model_id_2 = S_ModelingPre_InteractiveManager::getInstance()->model_CreateDiscretePort(p4, p3, QColor(205, 55, 0), QColor(205, 55, 0), false);
		QString model_id_3 = S_ModelingPre_InteractiveManager::getInstance()->model_CreateDiscretePort(p3, p2, QColor(205, 55, 0), QColor(205, 55, 0), false);
		QString model_id_4 = S_ModelingPre_InteractiveManager::getInstance()->model_CreateDiscretePort(p2, p1, QColor(205, 55, 0), QColor(205, 55, 0), false);
		modelId_list.append(model_id_1);
		modelId_list.append(model_id_2);
		modelId_list.append(model_id_3);
		modelId_list.append(model_id_4);
	}
	this->m_mapCurrentMonitor.insert(data_id, modelId_list);
}
void S_MonitorDisplayingManager::refreshModelAll_NoUpdate_CurrentMonitor() {
	if (this->m_block_refreshModel_CurrentMonitor == true) { return; }

	// > 清理模型
	this->clearModelAll_NoUpdate_CurrentMonitor();

	// > 遍历
	QStringList id_list = S_MonitorDataContainer::getInstance()->getDataCurrentMonitorAllId();
	for (int i = 0; i < id_list.count(); i++) {
		QString id = id_list.at(i);
		this->refreshModel_NoUpdate_CurrentMonitor(id);
	}
}
/*-----------------------------------
		电流监视器 - 清理模型
*/
void S_MonitorDisplayingManager::clearModel_NoUpdate_CurrentMonitor(QString data_id) {
	QStringList model_id_list = this->m_mapCurrentMonitor.value(data_id);
	if (model_id_list.count() == 0) { return; }
	for (int i = 0; i < model_id_list.count(); i++) {
		QString model_id = model_id_list.at(i);
		S_ModelingPre_InteractiveManager::getInstance()->model_destory(model_id, false);
	}
	this->m_mapCurrentMonitor.remove(data_id);
}
void S_MonitorDisplayingManager::clearModelAll_NoUpdate_CurrentMonitor() {
	QList<QStringList> modelId_tank = this->m_mapCurrentMonitor.values();
	for (int i = 0; i < modelId_tank.count(); i++) {
		QStringList model_id_list = modelId_tank.at(i);
		for (int j = 0; j < model_id_list.count(); j++) {
			QString model_id = model_id_list.at(j);
			S_ModelingPre_InteractiveManager::getInstance()->model_destory(model_id, false);
		}
	}
	this->m_mapCurrentMonitor.clear();
}
/*-----------------------------------
		电流监视器 - 阻塞刷新模型
*/
void S_MonitorDisplayingManager::block_refreshModel_NoUpdate_CurrentMonitor(bool enabled) {
	this->m_block_refreshModel_CurrentMonitor = enabled;
}
/*-----------------------------------
		电流监视器 - 设置数据显示（action）
*/
void S_MonitorDisplayingManager::action_show_CurrentMonitor() {
	QAction* cur_action = qobject_cast<QAction*>(this->sender());		//从action里面取出数据指针
	QString data_id = cur_action->data().value<QString>();

	S_MonitorDataContainer::getInstance()->setVisible_CurrentMonitor(data_id, true);
	this->refreshVisible_CurrentMonitor(data_id);
}
void S_MonitorDisplayingManager::action_showAll_CurrentMonitor() {
	S_MonitorDataContainer::getInstance()->setAllVisible_CurrentMonitor(true);
	this->refreshVisible_CurrentMonitorAll();
}
void S_MonitorDisplayingManager::action_hide_CurrentMonitor() {
	QAction* cur_action = qobject_cast<QAction*>(this->sender());		//从action里面取出数据指针
	QString data_id = cur_action->data().value<QString>();

	S_MonitorDataContainer::getInstance()->setVisible_CurrentMonitor(data_id, false);
	this->refreshVisible_CurrentMonitor(data_id);
}
void S_MonitorDisplayingManager::action_hideAll_CurrentMonitor() {
	S_MonitorDataContainer::getInstance()->setAllVisible_CurrentMonitor(false);
	this->refreshVisible_CurrentMonitorAll();
}

/*-----------------------------------
		电流监视器显示 - 刷新显示
*/
void S_MonitorDisplayingManager::refreshVisible_CurrentMonitor(QString data_id) {
	this->refreshVisible_CurrentMonitorNoSignal(data_id);

	// > 刷新视图+信号
	S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
	emit signal_visibleChanged_CurrentMonitor();
}

void S_MonitorDisplayingManager::refreshVisible_CurrentMonitorNoSignal(QString data_id) {
	QStringList model_id_list = this->m_mapCurrentMonitor.value(data_id);
	if (model_id_list.count() == 0) { return; }
	bool visible = true;

	// > 显示 - 内部隐藏列表 有此设置，则不显示
	if (this->m_customHideList_CurrentMonitor.contains(data_id)){
		visible = false;
	}

	// > 显示 - 如果选中了树节点，则根据树节点情况显示
	if (S_MonitorTreeManager::getInstance()->hasItemSelectedID_CurrentMonitor()) {
		QStringList selected_port_id = S_MonitorTreeManager::getInstance()->getItemSelectedID_CurrentMonitor();
		if (selected_port_id.contains(data_id)) {
			visible = true;
		}else {
			visible = false;
		}
	}

	// > 显示 - 数据隐藏列表 有此设置，则不显示（注意顺序，数据隐藏的优先级最高）
	QStringList hide_idList = S_MonitorDataContainer::getInstance()->getHideList_CurrentMonitor();
	if (hide_idList.contains(data_id)) { visible = false; }

	// > 显示 - 执行模型显示
	if (visible == true) {
		for (int i = 0; i < model_id_list.count(); i++) {
			QString model_id = model_id_list.at(i);
			S_ModelingPre_InteractiveManager::getInstance()->model_show(model_id, false);
		}
	}else{
		for (int i = 0; i < model_id_list.count(); i++) {
			QString model_id = model_id_list.at(i);
			S_ModelingPre_InteractiveManager::getInstance()->model_hide(model_id, false);
		}
	}
}
void S_MonitorDisplayingManager::refreshVisible_CurrentMonitorAll() {
	QStringList id_list = S_MonitorDataContainer::getInstance()->getDataCurrentMonitorAllId();
	for (int i = 0; i < id_list.count(); i++) {
		QString id = id_list.at(i);
		this->refreshVisible_CurrentMonitorNoSignal(id);
	}

	// > 刷新视图+信号
	S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
	emit signal_visibleChanged_CurrentMonitor();
}
/*-----------------------------------
		电流监视器显示 - 是否显示
*/
bool S_MonitorDisplayingManager::isVisible_CurrentMonitor(QString data_id) {
	QStringList model_id_list = this->m_mapCurrentMonitor.value(data_id);
	if (model_id_list.count() == 0) { return true; }
	return S_ModelingPre_VisibleManager::getInstance()->model_isShowing(model_id_list.first());
}
/*-----------------------------------
		电流监视器显示 - 设置隐藏列表（内部用）
*/
void S_MonitorDisplayingManager::setCustomHideList_CurrentMonitor(QStringList data_id_list) {
	this->m_customHideList_CurrentMonitor = data_id_list;
}
QStringList S_MonitorDisplayingManager::getCustomHideList_CurrentMonitor() {
	return this->m_customHideList_CurrentMonitor;
}




/*-----------------------------------
		电压监视器 - 刷新模型
*/
void S_MonitorDisplayingManager::refreshModel_NoUpdate_VoltageMonitor(QString data_id) {
	if (this->m_block_refreshModel_VoltageMonitor == true) { return; }

	// > 清理模型
	this->clearModel_NoUpdate_VoltageMonitor(data_id);

	// > 获取数据
	C_VoltageMonitor c_data = S_MonitorDataContainer::getInstance()->getDataVoltageMonitorById(data_id);
	if (c_data.isNull()) { return; }

	QStringList model_id_list;
	if (c_data.directionInverted == false) {		//（电压监视器 和 离散端口 使用相同模型）
		QString model_id = S_ModelingPre_InteractiveManager::getInstance()->model_CreateDiscretePort(
			gp_Pnt(c_data.x1, c_data.y1, c_data.z1), gp_Pnt(c_data.x2, c_data.y2, c_data.z2),
			QColor(120,120,120), QColor(0, 0, 255)
		);
		model_id_list.append(model_id);
	}else {
		QString model_id = S_ModelingPre_InteractiveManager::getInstance()->model_CreateDiscretePort(
			gp_Pnt(c_data.x2, c_data.y2, c_data.z2), gp_Pnt(c_data.x1, c_data.y1, c_data.z1),
			QColor(120, 120, 120), QColor(0, 0, 255)
		);
		model_id_list.append(model_id);
	}
	this->m_mapVoltageMonitor.insert(data_id, model_id_list);
}
void S_MonitorDisplayingManager::refreshModelAll_NoUpdate_VoltageMonitor() {
	if (this->m_block_refreshModel_VoltageMonitor == true) { return; }

	// > 清理模型
	this->clearModelAll_NoUpdate_VoltageMonitor();

	// > 遍历
	QStringList id_list = S_MonitorDataContainer::getInstance()->getDataVoltageMonitorAllId();
	for (int i = 0; i < id_list.count(); i++) {
		QString id = id_list.at(i);
		this->refreshModel_NoUpdate_VoltageMonitor(id);
	}
}
/*-----------------------------------
		电压监视器 - 清理模型
*/
void S_MonitorDisplayingManager::clearModel_NoUpdate_VoltageMonitor(QString data_id) {
	QStringList model_id_list = this->m_mapVoltageMonitor.value(data_id);
	if (model_id_list.count() == 0) { return; }
	for (int i = 0; i < model_id_list.count(); i++) {
		QString model_id = model_id_list.at(i);
		S_ModelingPre_InteractiveManager::getInstance()->model_destory(model_id, false);
	}
	this->m_mapVoltageMonitor.remove(data_id);
}
void S_MonitorDisplayingManager::clearModelAll_NoUpdate_VoltageMonitor() {
	QList<QStringList> modelId_tank = this->m_mapVoltageMonitor.values();
	for (int i = 0; i < modelId_tank.count(); i++) {
		QStringList model_id_list = modelId_tank.at(i);
		for (int j = 0; j < model_id_list.count(); j++) {
			QString model_id = model_id_list.at(j);
			S_ModelingPre_InteractiveManager::getInstance()->model_destory(model_id, false);
		}
	}
	this->m_mapVoltageMonitor.clear();
}
/*-----------------------------------
		电压监视器 - 阻塞刷新模型
*/
void S_MonitorDisplayingManager::block_refreshModel_NoUpdate_VoltageMonitor(bool enabled) {
	this->m_block_refreshModel_VoltageMonitor = enabled;
}
/*-----------------------------------
		电压监视器 - 设置数据显示（action）
*/
void S_MonitorDisplayingManager::action_show_VoltageMonitor() {
	QAction* cur_action = qobject_cast<QAction*>(this->sender());		//从action里面取出数据指针
	QString data_id = cur_action->data().value<QString>();

	S_MonitorDataContainer::getInstance()->setVisible_VoltageMonitor(data_id, true);
	this->refreshVisible_VoltageMonitor(data_id);
}
void S_MonitorDisplayingManager::action_showAll_VoltageMonitor() {
	S_MonitorDataContainer::getInstance()->setAllVisible_VoltageMonitor(true);
	this->refreshVisible_VoltageMonitorAll();
}
void S_MonitorDisplayingManager::action_hide_VoltageMonitor() {
	QAction* cur_action = qobject_cast<QAction*>(this->sender());		//从action里面取出数据指针
	QString data_id = cur_action->data().value<QString>();

	S_MonitorDataContainer::getInstance()->setVisible_VoltageMonitor(data_id, false);
	this->refreshVisible_VoltageMonitor(data_id);
}
void S_MonitorDisplayingManager::action_hideAll_VoltageMonitor() {
	S_MonitorDataContainer::getInstance()->setAllVisible_VoltageMonitor(false);
	this->refreshVisible_VoltageMonitorAll();
}

/*-----------------------------------
		电压监视器显示 - 刷新显示
*/
void S_MonitorDisplayingManager::refreshVisible_VoltageMonitor(QString data_id) {
	this->refreshVisible_VoltageMonitorNoSignal(data_id);

	// > 刷新视图+信号
	S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
	emit signal_visibleChanged_VoltageMonitor();
}

void S_MonitorDisplayingManager::refreshVisible_VoltageMonitorNoSignal(QString data_id) {
	QStringList model_id_list = this->m_mapVoltageMonitor.value(data_id);
	if (model_id_list.count() == 0) { return; }
	bool visible = true;

	// > 显示 - 内部隐藏列表 有此设置，则不显示
	if (this->m_customHideList_VoltageMonitor.contains(data_id)) {
		visible = false;
	}

	// > 显示 - 如果选中了树节点，则根据树节点情况显示
	if (S_MonitorTreeManager::getInstance()->hasItemSelectedID_VoltageMonitor()) {
		QStringList selected_port_id = S_MonitorTreeManager::getInstance()->getItemSelectedID_VoltageMonitor();
		if (selected_port_id.contains(data_id)) {
			visible = true;
		}
		else {
			visible = false;
		}
	}

	// > 显示 - 数据隐藏列表 有此设置，则不显示（注意顺序，数据隐藏的优先级最高）
	QStringList hide_idList = S_MonitorDataContainer::getInstance()->getHideList_VoltageMonitor();
	if (hide_idList.contains(data_id)) { visible = false; }

	// > 显示 - 执行模型显示
	if (visible == true) {
		for (int i = 0; i < model_id_list.count(); i++) {
			QString model_id = model_id_list.at(i);
			S_ModelingPre_InteractiveManager::getInstance()->model_show(model_id, false);
		}
	}
	else {
		for (int i = 0; i < model_id_list.count(); i++) {
			QString model_id = model_id_list.at(i);
			S_ModelingPre_InteractiveManager::getInstance()->model_hide(model_id, false);
		}
	}
}
void S_MonitorDisplayingManager::refreshVisible_VoltageMonitorAll() {
	QStringList id_list = S_MonitorDataContainer::getInstance()->getDataVoltageMonitorAllId();
	for (int i = 0; i < id_list.count(); i++) {
		QString id = id_list.at(i);
		this->refreshVisible_VoltageMonitorNoSignal(id);
	}

	// > 刷新视图+信号
	S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
	emit signal_visibleChanged_VoltageMonitor();
}
/*-----------------------------------
		电压监视器显示 - 是否显示
*/
bool S_MonitorDisplayingManager::isVisible_VoltageMonitor(QString data_id) {
	QStringList model_id_list = this->m_mapVoltageMonitor.value(data_id);
	if (model_id_list.count() == 0) { return true; }
	return S_ModelingPre_VisibleManager::getInstance()->model_isShowing(model_id_list.first());
}
/*-----------------------------------
		电压监视器显示 - 设置隐藏列表（内部用）
*/
void S_MonitorDisplayingManager::setCustomHideList_VoltageMonitor(QStringList data_id_list) {
	this->m_customHideList_VoltageMonitor = data_id_list;
}
QStringList S_MonitorDisplayingManager::getCustomHideList_VoltageMonitor() {
	return this->m_customHideList_VoltageMonitor;
}



/*-----------------------------------
		数据容器 - 模型变化 - 某数据 被添加
*/
void S_MonitorDisplayingManager::containerDataAdded(C_UndoDataBasePtr ptr, int index) {
	if (ptr->get__CLASS_NAME__() == "C_FieldProbe") {
		this->refreshModel_NoUpdate_Probe(ptr->getId());
		if (this->m_block_refreshModel_Probe == false) {
			S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
		}
	}
	if (ptr->get__CLASS_NAME__() == "C_VoltageMonitor") {
		this->refreshModel_NoUpdate_VoltageMonitor(ptr->getId());
		if (this->m_block_refreshModel_VoltageMonitor == false) {
			S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
		}
	}
	if (ptr->get__CLASS_NAME__() == "C_CurrentMonitor") {
		this->refreshModel_NoUpdate_CurrentMonitor(ptr->getId());
		if (this->m_block_refreshModel_CurrentMonitor == false) {
			S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
		}
	}
}
/*-----------------------------------
		数据容器 - 模型变化 - 某数据 被修改
*/
void S_MonitorDisplayingManager::containerDataModifyed(C_UndoDataBasePtr ptr, int index) {
	if (ptr->get__CLASS_NAME__() == "C_FieldProbe") {
		this->refreshModel_NoUpdate_Probe(ptr->getId());
		if (this->m_block_refreshModel_Probe == false) {
			S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
		}
	}
	if (ptr->get__CLASS_NAME__() == "C_VoltageMonitor") {
		this->refreshModel_NoUpdate_VoltageMonitor(ptr->getId());
		if (this->m_block_refreshModel_VoltageMonitor == false) {
			S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
		}
	}
	if (ptr->get__CLASS_NAME__() == "C_CurrentMonitor") {
		this->refreshModel_NoUpdate_CurrentMonitor(ptr->getId());
		if (this->m_block_refreshModel_CurrentMonitor == false) {
			S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
		}
	}
}
/*-----------------------------------
		数据容器 - 模型变化 - 某数据 被删除
*/
void S_MonitorDisplayingManager::containerDataDeleted(C_UndoDataBasePtr ptr, int index) {
	if (ptr->get__CLASS_NAME__() == "C_FieldProbe") {
		this->refreshModel_NoUpdate_Probe(ptr->getId());
		if (this->m_block_refreshModel_Probe == false) {
			S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
		}
	}
	if (ptr->get__CLASS_NAME__() == "C_VoltageMonitor") {
		this->refreshModel_NoUpdate_VoltageMonitor(ptr->getId());
		if (this->m_block_refreshModel_VoltageMonitor == false) {
			S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
		}
	}
	if (ptr->get__CLASS_NAME__() == "C_CurrentMonitor") {
		this->refreshModel_NoUpdate_CurrentMonitor(ptr->getId());
		if (this->m_block_refreshModel_CurrentMonitor == false) {
			S_ModelingPre_InteractiveManager::getInstance()->updateViewModeling();
		}
	}
}
/*-----------------------------------
		数据容器 - 模型变化 - 某全局数据 被修改
*/
void S_MonitorDisplayingManager::containerGlobalDataModifyed(C_UndoDataGlobalBasePtr ptr) {
	
	//...

}
/*-----------------------------------
		数据容器 - 模型变化 - 存储数据 被读取
*/
void S_MonitorDisplayingManager::containerDataAllReloaded() {
	this->rebuildAll();
}

